<?php 
//print_r($HttpResult);
if(1==2){$HttpResult = new HttpResult();}

	  $HttpContentResult = $HttpResult->getHttpContentResult();
	  // Debug::print_r($HttpContentResult);
	  //$lang = Config::DEFAULT_LOCALE;
		$head = new HtmlHeader($HttpContentResult->getHeader());
		$head->addCSS('reset');
		$head->addCSS('print','', 'print');
		$head->addCSS('ie',  'css/ie', 'print',true);
		
		$head->addCSS('forum',"css/admin");		
		
		//<!-- PROGRAMACAO JS | JQUERY  -->
		$head->addJS(array('jquery', 'masked'));
		
    //MENU DROPDOWN
    $head->addJS('Menu principal','js/menu/ddsmoothmenu');
    $head->addCSS('Menu CSS','js/menu/ddsmoothmenu');
    
    //TINYMCE
    $head->addJS('tinymce','js/tinymce/jquery.tinymce');
    
    //FILEUPLOAD
    $head->addJS('so','js/uploadify/swfobject');
    $head->addJS('uploadify','js/uploadify/jquery.uploadify.v2.1.4.min');
    $head->addCSS('Upload CSS','js/uploadify/uploadify');
		       
		//SLIDER SHOW
		$head->addJS('cycle', 'js/cycle/jquery.cycle.min');
	
		//<!-- JQUERY UI  -->
		$head->addJS('UI', 'js/UI/js/jquery-ui-1.8.6.custom.min');
		$head->addCSS('UI','js/UI/css/smoothness/jquery-ui-1.8.6.custom');
		
     //SELECTMENU
    $head->addJS('selectmenu','js/UI/development-bundle/ui/jquery.ui.selectmenu');
    $head->addCSS('selectmenu CSS','js/UI/css/jquery.ui.selectmenu');
    
		//<!-- VTIP  -->
		$head->addJS('vtip', 'js/vtip/vtip');
		$head->addCSS('vtip', 'js/vtip/vtip');
		
		//<!-- TABLE SORTER -->
		$head->addJS('tablesorter', 'js/tablesorter/tablesorter');
		$head->addCSS('tablesorter', 'js/tablesorter/tablesorter');
    
    //<!-- PROGRAMACAO JS | JQUERY  -->
    $head->addJS(array('admin','admin_select', 'admin/afiliate_salles/list'));
		
	$header_html = $head->show(TRUE);
$header_html = str_replace(array("democrart", "democrArt", "Democrart", "DemocrArt"), array("expressaoartistica", "Expressão Artística", "Expressão Artística", "Expressão Artística"), $header_html);
echo $header_html;
	
?>
 
<body>

<div id="main">
      <?php include "view/democrart/parts/admin/header.php" ?>
      
	  <div id="main_content">
	  
	  <div id="msgBox"></div>
<?php $search_active = DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active"); ?>

		 <div id="box_right">
			<h1>Listar Vendas dos Afiliados <?php echo ($search_active == 1)?"Pendentes":"Pagos"; ?></h1>
			<?php
			
			
			if(DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "filtro") != "" || DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "date_init") != "" || DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "date_end") != ""){
				$filtro = DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "filtro");
				if($filtro == "partner_id"){
					$filtro = "Parceiro Id";
				}
				if($filtro == "purchase_order_id"){
					$filtro = "Pedido Id";
				}
				$busca	= DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "busca");

				$date_init 			= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "date_init"));
				$date_end 			= (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "date_end"));				

				if($date_init != ""){
					$date_init = "Data Inicial ".$date_init;
				}
				if($date_end != ""){
					$date_end = "Data Final ".$date_end;
				}
				
			?>
			<div id="avisoFiltro">Filtrado por: <?php echo $filtro?> <?php echo $busca;?> <?php echo $date_init; ?>  <?php echo $date_end ?>:
			<a href="<?php echo Config::getRootPath("admin/afiliate_salles/active.".DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active"));?>">
				 remover filtro <img src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="remover filtro"></img>
			</a>
			</div>
			<?php } ?>
			<div style="clear:both">
				<form id="frmFilter" name="frmFilter" method="post" action="#" class="filter">
					<table>
						<tr>
							<td><span class="count"><?php echo $HttpContentResult->count_total; ?> registro(s)</span></td>
							<input type="hidden" name="pesquisa_date_active" id="pesquisa_date_active" size="15" value="<?php echo (DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active")?DataHandler::getValueByArrayIndex($HttpContentResult->arrayVariable, "active"):1); ?>"/>
						</tr>
						<tr>
							<td><strong>Data Inicial: </strong>
								<input type="text" name="pesquisa_date_start" id="pesquisa_date_start" size="15" />
							</td>
						</tr>
						<tr>
							<td><strong>Data Final: </strong>
								<input type="text" name="pesquisa_date_finish" id="pesquisa_date_finish" size="15" />
							</td>
						</tr>
						<tr style="display:block;">
							<td><strong>Filtrar: </strong>
								<input type="text" name="pesquisa" id="pesquisa_afiliate_salles" size="25" />
							</td>
							<td>
								<select name="filtro" id="filtro_afiliate_salles">
									<option  value="partner_id">Parceiro Id</option>
									<option  value="purchase_order_id" selected="selected" >Pedido Id</option>
								</select>
							</td>
							<td><a href="javascript:void(0);" onclick="AfiliateSalles.search($('#pesquisa_date_active').val(), $('#pesquisa_afiliate_salles').val(), $('#filtro_afiliate_salles').val(), $('#pesquisa_date_start').val(), $('#pesquisa_date_finish').val())" class="button">Filtrar</a></td>
						</tr>
						
					</table>
				</form>
				
				<table class="tablesorter">
					<thead>
						<tr>
							<th>Parceiro Id</th>
							<th>Pedido id</th>
							<th>Data da Compra</th>
							<th>Valor</th>							
							<th>Editar</th>
<!-- 							<th>Excluir</th> -->
						</tr>
					</thead>
					<tbody>
					<?php
					if(count($HttpContentResult->arrayAfiliateSalles) > 0){
						//tem resultados a mostrar 
						// Debug::print_r($HttpContentResult->arrayAfiliateSalles);exit();
						foreach($HttpContentResult->arrayAfiliateSalles as $salle){
						?>
						<tr id="salle_<?php echo $salle->id ?>">
							<td><?php echo $salle->partner_id; ?></td>
							<td><?php echo $salle->purchase_order_id; ?></td>
							<td><?php echo $salle->getDateSale(); ?></td>
							<td><?php echo DataHandler::convertMoneyToBrazil($salle->value); ?></td>						
							<td class="ico"><a href="<?php echo Config::getRootPath("admin/afiliate_salles/update/id.".$salle->id) ?>">
							<img id="edit1" src="<?php echo Config::getAsset("assets/img/icons/edit.jpg");?>" alt="Editar" title="" /></a></td>
<!-- 							<td class="ico"><a class="del" name="salle" id="<?php echo $salle->id ?>" href="<?php echo Config::getRootPath("admin/afiliate_salles/delete/id.".$salle->id) ?>"> -->
<!-- 							<img id="del1" src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="Excluir" title="" /></td> -->
						</tr>
					<?php 
						}//end foreach
					} else {
						//aqui não tem resultados a mostrar
					?>
					<tr id="salle_0">
							<td colspan="7">Nenhum resultado encontrado</td>
						</tr>
					<?php }?>
					</tbody>
				</table>
			</div>
			
			<!-- COMECO PAGINACAO -->
			<div style="clear: both;"></div>
			<div id="model-pagination" style="text-align: center;padding: 20px 0px 20px 0px;">
			<?php 
				include_once("library/facil3/utils/Pagination.class.php");
				$Pagination = new Pagination($HttpContentResult->page, $HttpContentResult->limit_page, $HttpContentResult->count_total);
				$htmlPaginacao = $Pagination->getHtml();
				echo $htmlPaginacao;
			?>
			
			</div>
		
		</div>
					
			
			<!-- FIM DO QUADRO -->
	
	</div>
	
</div>

</body>
</html>
